home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Scripts / TransferCKID < prev    next >
Encoding:
Text File  |  1993-05-07  |  1.7 KB  |  65 lines  |  [TEXT/MPS ]

  1. #    TransferCkid - Move the ckid resource from fromFile to toFile.
  2. #
  3. #    Usage:    TransferCKID fromFile toFile
  4. #
  5. #    TransferCKID moves the ckid resource (if it exists) from the
  6. #    first file to the second file. 
  7. #
  8. #    © Apple Computer, Inc. 1988 - 1993
  9. #    All rights reserved.
  10.  
  11. Set Exit 0
  12. Unset CaseSensitive
  13.  
  14. #    Check the parameters
  15.  
  16. IF {#} ≠ 2
  17.     Echo "### Usage - {0} fromFile toFile" > dev:stderr
  18.     Exit 1
  19. END
  20.     
  21. #    Check if files exist
  22.  
  23. FOR name in "{1}" "{2}"
  24.     IF "`Exists -f "{name}"`"!=""
  25.         Set curPath `Files -fr "{name}"`
  26.         Set path"{Name}" "{curPath}"
  27.         Set wind"{Name}" 0
  28.         FOR i in `Windows`
  29.             IF "{curPath}" =~ /"{i}"/        ## Make NOT case-sensitive
  30.                 Set wind"{Name}" 1
  31.             END
  32.         END
  33.     ELSE    
  34.         IF "`Exists -d "{name}"`" == ""
  35.             Echo "### {0}" - File "'{name}'" does not exist. >> dev:stderr
  36.         ELSE
  37.             Echo "### {0}" - File "'{name}'" is a folder. >> dev:stderr
  38.         END
  39.         Exit 2
  40.     END
  41. END
  42.     
  43.  
  44.     #    Transfer the ckid
  45.     
  46.     Echo "Include ∂"{1}∂" 'ckid';" | Rez -m -a -o "{2}" -noResolve    ## copy resource into destination
  47.     IF {Status} == 0
  48.         Echo "Delete 'ckid';" | Rez -a -o "{1}"        ## delete it from source
  49.         FOR name in "{1}" "{2}"                        ## refresh relevant windows for projector icon.
  50.             (evaluate "`set wind"{name}"`" =~ /set ?«0,1»wind{name}?«0,1» (≈)®1/) >> Dev:Null
  51.             IF "{®1}"                                ## is this an open window?
  52.                 Execute `Format "{name}"` ∑dev:null    ## Force the shell to recognize that the file's been changed
  53.                 Save "{name}"                        ## Force the shell to save the file to disk
  54.                 (evaluate "`set path"{name}"`" =~ /set ?«0,1»path{name}?«0,1» (≈)®2/) >> Dev:Null
  55.                 IF "{®2}" =~ /"{active}"/            ## is this our frontmost window?
  56.                     Close "{name}"
  57.                     Open "{name}"
  58.                 ELSE
  59.                     Close "{name}"
  60.                     Target "{name}"
  61.                 END
  62.             END
  63.         END
  64.     END
  65.